package __linked_list

import "fmt"

/**
链表
*/

type Node struct {
	data int
	next *Node
}

func walkNode(node *Node) {
	fmt.Println("node.data=", node.data)
	if node.next == nil {
		return
	}
	walkNode(node.next)
}

// 没有头结点
func printNode(node *Node) {
	for node != nil {
		fmt.Print(node.data)
		node = node.next
	}
}

func printLinkedList() int {
	n3 := &Node{data: 3, next: nil}
	n2 := &Node{data: 2, next: n3}
	n1 := &Node{data: 1, next: n2}
	head := &Node{data: 0, next: n1}
	//walkNode(head)
	printNode(head)
	return 0
}
